package com.smrs.basicdata.webapp.action;

import org.apache.commons.lang.StringUtils;

import com.jof.framework.util.Pager;
import com.smrs.basicdata.model.SystemConfigModel;
import com.smrs.security.model.UserModel;
import com.smrs.util.AppUtil;


public class SystemConfigAction  extends BaseBasicDataAction{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected String titleName="系统配置";
	protected SystemConfigModel systemConfig;
	protected Pager<SystemConfigModel> pager = new Pager<SystemConfigModel>(); 
	
	public Pager<SystemConfigModel> getPager() {
		return pager;
	}

	public void setPager(Pager<SystemConfigModel> pager) {
		this.pager = pager;
	}

	public SystemConfigModel getSystemConfig() {
		return systemConfig;
	}

	public void setSystemConfig(SystemConfigModel systemConfig) {
		this.systemConfig = systemConfig;
	}

	public String getTitleName() {
		return titleName;
	}
	
	public String searchSystemConfig(){
		if(systemConfig==null){
			systemConfig = new SystemConfigModel();
		}
		pager = this.systemConfigService.getByNameLikePager(systemConfig.getName(), pager);
		return SUCCESS;
	}
	
	public String updateSystemConfig(){		
		if(StringUtils.isEmpty(this.actionCommand)){			
			systemConfig = systemConfigService.getByPK(systemConfig.getId());	
		}else{
			UserModel userModel = this.getUserModelFromSession();
			AppUtil.setUpdateUserInfo(userModel, systemConfig);
			systemConfigService.updateModel(systemConfig);
			//this.preparePageSelectList();	
			this.addActionMessage("修改成功");			
			
		}
		return SUCCESS;
	}
}
